﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ooaavee.Data.Model;

namespace Ooaavee.Data.Queries
{
    public static class QueryExtensionMethods
    {

        public static QueryResult Select(this Table table)
        {
            QueryContext context = QueryContext.GetMappedContext(table);

            IQuery query = QueryFactory.CreateDirectTableQuery(context, table);

            QueryResult result = query.Execute();

            return result;
        }

        public static QueryResult Select(this Table table, string customClause)
        {
            if (customClause == null)
            {
                throw new ArgumentNullException("customClause");
            }

            QueryContext context = QueryContext.GetMappedContext(table);

            IQuery query = QueryFactory.CreateDirectTableQuery(context, table, customClause);

            QueryResult result = query.Execute();

            return result;
        }
        


    }
}
